Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@tylerkaraszewski accidentally opened instead of draft - please ignore for now |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf8612e8a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // One batched removal = one cross-tab sync event instead of one per key. A failed removal is | ||
| // logged, not retried — keysToRemove cannot be re-derived after the cache update. | ||
| const storagePromises = [Storage.multiSet(keyValuePairs)]; | ||
| const storagePromises = [Storage.multiSet(keyValuePairsToStore)]; |
There was a problem hiding this comment.
Do not record empty bulk batches as successful writes
When a native capacity-eviction retry is outstanding and another bulk request filters down to zero changed pairs, this still invokes Storage.multiSet([]). The SQLite provider resolves that without I/O (lib/storage/providers/SQLiteProvider.ts:273–275), but the following recordWriteSuccess() clears the outstanding eviction's no-progress streak or closes a half-open breaker despite no write succeeding. Interleaved unchanged bulk updates can therefore defeat the five-eviction safety limit while real writes continue failing. Skip empty writes and their success recording in this path, multiSetWithRetry, and partialSetCollection.
Useful? React with 👍 / 👎.
|
@fabioh8010 @LukasMod Can you please review? |
There was a problem hiding this comment.
@jmusial I didn't find any issues in the changes
Two older PRs tried something very similar (keeping the cached object for deep-equal collection members). Both were reverted after deploy blockers:
- #693, reverted in #699. Deleted splits came back offline, deleted expenses stayed on the report preview with infinite loading, and Split/Hold/Merge disappeared after reverting a split (Expensify/App#74405, Expensify/App#74406, Expensify/App#74385). Removed members had stopped getting notified. This PR still notifies them so I guess those are not an issue
- #707, reverted in #712. Review duplicates opened empty (Expensify/App#76847). Nobody found the root cause, this maybe worth to recheck
I see this PR goes a bit further. Could you recheck those flows on the linked App PR?
cc @TMisiukiewicz as you tried something similar before
|
Thanks for finding those @LukasMod, I think the linked deploy blockers are good examples to verify what can go wrong and check if this solution is bulletproof. It's been a while but I remember I tried to fix the exact same issue, unfortunately I did not come up with anything better after two reverts. Happy to see another attempt 🙏 |
Details
[WiP] This is a proposal POC PR
Onyx.setalready keeps the cached object when the incoming value is deep-equal to it (cache.hasValueChanged). The bulk set paths (multiSet,setCollection,partialSetCollection, andOnyx.updatewithSET/SET_COLLECTION/MULTI_SET) did not. They replaced every member with a new object, even when nothing changed. Every subscriber of those members then saw a new reference and re-rendered.This PR makes the bulk set paths behave like
set:prepareKeyValuePairsForStorage, so nestednulls are already stripped.setCollectionreplacing the whole collection) are still notified withundefined.inFlightKeysstill covers all keys, so eviction protection is unchanged.fastMergealready returns the existing reference when nothing changed.The extra deep-equal check costs time when every member really changed. To keep that cost low,
hasValueChangednow runs a cheap pre-check first (utils.hasTopLevelPrimitiveChange). If any top-level primitive field differs, it returns early without the fulldeepEqual. The pre-check never reports a change thatdeepEqualwould not, so results are the same.Trade-off: like
set, the first attempt doesn't rewrite an unchanged value to storage. If storage ever drifted from the cache for that key, this write won't fix it.Benchmarks (Reassure, ABBA, 4 rounds)
setCollection10k members, all changed (existing)partialSetCollection10k, half same objectsmerge10k callssetCollectionwith one member changed (new)setCollectionwith deep-equal members (new)Related Issues
GH_LINK
Linked E/App PR
Automated Tests
Manual Tests
OnyxUpdatesLastUpdateIDAppliedToClient, then send a message in any chat from the second deviceReconnectApprequest withoutupdateIDFromAuthor Checklist
### Related Issuessection above### Linked E/App PRsection above, and verified this change against it (E/App CI passed and manual testing completed)TestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari